﻿@model List<DauGiaApp.Models.LoaiSanPham>
 
<script src="../../Scripts/osx/js/jquery.js" type="text/javascript"></script>
<script src="../../Scripts/osx/js/jquery.simplemodal.js" type="text/javascript"></script>
<script src="../../Scripts/osx/js/osx.js" type="text/javascript"></script>
@{
    
    var grid = new WebGrid(Model,
        canPage: true,
        ajaxUpdateContainerId:"grid",
        ajaxUpdateCallback: "UpdateGridBinding",
        rowsPerPage: 5);        
        grid.Pager(WebGridPagerModes.NextPrevious);
    
    
    
    <div class="webgrid-title">Danh sách loại sản phẩm</div>
        <div id="grid">
            @grid.GetHtml(tableStyle: "webGrid",
                    htmlAttributes: new { id = "DataTable" },
                    headerStyle: "webgrid-header",
                    footerStyle: "webgrid-footer",
                    alternatingRowStyle: "webgrid-alternating-rows",
                    selectedRowStyle: "select",
                    columns: grid.Columns(
                        grid.Column("MaLoaiSanPham"),
                        grid.Column("TenLoaiSanPham"),
                        grid.Column(format: (item) => Html.Raw("<a href='#' id='" + item.MaLoaiSanPham + "' ten='" + item.TenLoaiSanPham
                                                                    + "' class='osx' >Cập nhật</a>")),
                        grid.Column(format: (item) => Html.Raw("<a href='#' class='del' idlsp='" + item.MaLoaiSanPham
                                                + "'>Xóa</a>"))
                 ))       
        </div>

}

<script type="text/javascript">
    $("a.osx").click(function () {
        var id = $(this).attr('id');
        var ten = $(this).attr('ten');
        PushFormValue(id, ten);

    });

    $("a.del").click(function () {
        var id = $(this).attr('idlsp');
        XoaLoaiSanPham(id);
    });
</script>